package net.hn.hnms.biz.safety.fiber.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import net.hn.hnms.biz.api.safety.monitor.model.ChartVo;
import net.hn.hnms.biz.safety.fiber.domain.AlarmDataVo;
import net.hn.hnms.biz.safety.fiber.domain.FiberDevice;
import net.hn.hnms.biz.safety.fiber.service.FiberService;
import net.hn.hnms.sys.common.core.domain.R;
import net.hn.hnms.sys.common.core.domain.ResponsePage;
import net.hn.hnms.sys.common.core.utils.StringUtils;
import net.hn.hnms.sys.common.satoken.config.AutoSetMineCode;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * Author: PanSX
 * Date: 2023/4/18 16:10
 */
@RestController
@RequestMapping("riskMonitor/fiber")
@Api(value = "光纤测温", tags = {"光纤测温"})
public class FiberController {
    @Autowired
    private FiberService fiberService;

    @GetMapping("selectDate")
    @ApiOperation("下拉选择数据")
    @AutoSetMineCode
    public R<List<FiberDevice>> selectDate(String mineCode) {
        return R.ok(fiberService.queryDevice(mineCode));
    }

    @GetMapping("realData")
    @ApiOperation("实时曲线")
    @AutoSetMineCode
    public R<String[]> realData(String deviceId, String channelId, String mineCode) {
        String s = fiberService.realData(deviceId, channelId, mineCode);
        if (StringUtils.isNotBlank(s)) {
            return R.ok(s.split(","));
        }
        return R.ok(new String[0]);
    }

    @GetMapping("getAlarmTable")
    @ApiOperation("报警表格")
    @AutoSetMineCode
    public R<ResponsePage<AlarmDataVo>> getAlarmTable(String deviceId, String channelId, String mineCode, int page) {
        return R.ok(fiberService.getAlarmTable(deviceId, channelId, mineCode, page));
    }
    @GetMapping("getTemperatureTrend")
    @ApiOperation("一周温度趋势")
    @AutoSetMineCode
    public R<ChartVo> getTemperatureTrend(String deviceId, String channelId, String mineCode) {
        return R.ok(fiberService.getTemperatureTrend(deviceId, channelId, mineCode));
    }
}
